﻿using System.Windows.Media;
using DimensionsHelper.Client.Helpers;
using DimensionsHelper.Common.Contracts.TableFormatter.Options;

namespace DimensionsHelper.Client.ViewModels.CsvFormatter;

public partial class SigComparisonViewModel : ObservableObject
{
    [ObservableProperty]
    private Color _charAtAnotherColumnColor = Colors.Transparent;


    [ObservableProperty]
    private Color _charAtMarkColumnColor = Colors.Transparent;


    [ObservableProperty]
    private ObservableCollection<string> _conflictOperations = [];


    [ObservableProperty]
    private string _expression = string.Empty;


    [ObservableProperty]
    private bool _markAtAnotherColumn;


    [ObservableProperty]
    private bool _markAtFirstColumn = true;


    [ObservableProperty]
    private string _markColumnTypeName = EnumStringCache.SigComparisonMarkTypeNames[0];


    [ObservableProperty]
    private SigComparisonMarkType _markType;


    [ObservableProperty]
    private string _startStringToSkip = string.Empty;


    public SigComparisonViewModel()
    {
        PropertyChanged += OnMarkPropertyChanged;
    }


    private void OnMarkPropertyChanged(object? sender, PropertyChangedEventArgs e)
    {
        if (e.PropertyName?.Equals(nameof(MarkColumnTypeName)) != true)
        {
            return;
        }

        if (MarkColumnTypeName == EnumStringCache.SigComparisonMarkTypeNames[0])
        {
            MarkAtFirstColumn = true;
            MarkAtAnotherColumn = false;
        }
        else
        {
            MarkAtFirstColumn = false;
            MarkAtAnotherColumn = true;
        }
    }


    public void JoinExpression(string expression)
    {
        if (string.IsNullOrEmpty(Expression))
        {
            Expression = expression;
        }
        else
        {
            Expression += "," + expression;
        }
    }
}